#include <stdio.h>

void HexLog(char *t_data, int len)
{
	int i;
	char a;

	for( i = 0;i < len;i++) {	
		if (!(i % 16))
			fprintf(stdout, "[%04X]:", i);

		if ( ((*(t_data + i)) >0x21) && ((*(t_data + i)) <=0x7e)){
			a = *(t_data + i);
		} else {
			a = ' ';
		}
		
		fprintf(stdout, "%02X%c ", (unsigned char)*(t_data + i), a);
		if (!((i + 1)% 16))
			fprintf(stdout, "\n", i);
	}
	fprintf(stdout, "\n", i);

}

int HexChkPr(char *a_data, char *b_data, int len)
{
	int i;
	char a;
  int ret = 0;
  
  fprintf(stdout, "* Hex. Check(len:%d)\n", len);

	for( i = 0;i < len;i++) {	
		if (!(i % 16))
			fprintf(stdout, "[%04X]:", i);

		if ( *(a_data + i) == *(b_data + i)){
			a = 'O';
		} else {
			a = 'X';
			ret = 1;
		}
		
		fprintf(stdout, "%02X%c ", (unsigned char)*(a_data + i), a);
		if (!((i + 1)% 16))
			fprintf(stdout, "\n", i);
	}
	fprintf(stdout, "\n", i);
  return(ret);
}
#if 0
main()
{
	char aa [20];

	strcpy(aa, "abcdefhijklmnopqrstu");

	HexLog(aa, 20);
}
#endif
